package com.disapand.mybaby.exception;

import lombok.Getter;

@Getter
public class ApiException extends RuntimeException {
    
    /**
     * 给可序列化的( Serializable )对象配置 serialVersionUID
     */
    private static final long serialVersionUID = 1L;

    /**
     * 定义错误码
     */
    private int code;

    /**
     * 定义异常信息
     */
    private String msg;

    /**
     * 生成默认的异常状态
     */
    public ApiException () {
        this(1001, "接口错误");
    }

    /**
     * 根据异常提示信息生成异常状态
     * @param msg
     */
    public ApiException (String msg) {
        this(1001, msg);
    }

    /**
     * 根据错误码和异常提示信息生成异常状态
     * @param code
     * @param msg
     */
    public ApiException (int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }
}
